package com.data.monitoring.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.data.monitoring.utils.CryptoConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.persistence.*;

/**
 * <p>
 * 服务器基本信息
 * </p>
 *
 * @author HanYiMing
 * @since 2025-05-28
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("servers")
@ApiModel(value = "Servers对象", description = "服务器基本信息")
public class Servers extends Model<Servers> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "server_id", type = IdType.AUTO)
    private Integer serverId;

    @ApiModelProperty("服务器名称")
    @TableField("server_name")
    private String serverName;

    @ApiModelProperty("IP地址")
    @TableField("ip_address")
    private String ipAddress;

    @ApiModelProperty("SSH端口")
    @TableField("ssh_port")
    private Integer sshPort;

    @ApiModelProperty("登录用户名")
    @TableField("username")
    @Convert(converter = CryptoConverter.class)
    private String username;

    @ApiModelProperty("认证方式")
    @TableField("auth_method")
    @Enumerated(EnumType.STRING)
    private String authMethod;

    @ApiModelProperty("密钥或密码(加密存储)")
    @TableField("auth_key")
    @Convert(converter = CryptoConverter.class)
    private String authKey;

    @ApiModelProperty("服务器描述")
    @TableField("description")
    private String description;

    @ApiModelProperty("是否启用监控")
    @TableField("is_active")
    private Boolean active;

    @TableField("created_at")
    private LocalDateTime createdAt;

    @TableField("updated_at")
    private LocalDateTime updatedAt;

    @Override
    public Serializable pkVal() {
        return this.serverId;
    }
}

